<?php
namespace Swiftx\DataBase\Driver;
use Swiftx\DataBase\Exception;
use Swiftx\DataBase\IDriver;
use Swiftx\DataBase\Page;
use Swiftx\DataBase\Picker;
use Swiftx\DataBase\Sql;

/**
 * ---------------------------------------------------------------------------------------------------------------
 * 数据库对象
 * ---------------------------------------------------------------------------------------------------------------
 * @author      胡永强 <odaytudio@gmail.com>
 * @since       2014-11-06
 * @copyright   Copyright (c) 2014-2015 ymaplus Inc.
 * ---------------------------------------------------------------------------------------------------------------
 */
class Mysqli extends IDriver {

    /**
     * 进行数据库连接
     * @throws Exception
     * @return mixed
     */
    protected function Connect(){
        $connection = mysqli_connect(
            $this->_connect->Host, $this->_connect->Username,
            $this->_connect->Password, $this->_connect->Name,
            $this->_connect->Port, $this->_connect->Socket
        );
        if ($connection) return $connection;
        throw new Exception('数据库连接失败', 301);
    }


    /**
     * ----------------------------------------------------------
     * 数据库查询
     * ----------------------------------------------------------
     * @param $sql
     * ----------------------------------------------------------
     * @return array
     * ----------------------------------------------------------
     */
    public function Query($sql)
    {
        // TODO: Implement Query() method.
    }

    /**
     * ----------------------------------------------------------
     * 获取一条记录
     * ----------------------------------------------------------
     * @param Sql $sql
     * ----------------------------------------------------------
     * @return array
     * ----------------------------------------------------------
     */
    public function QueryRow(Sql $sql)
    {
        // TODO: Implement QueryRow() method.
    }

    /**
     * ----------------------------------------------------------
     * 获取多条记录
     * ----------------------------------------------------------
     * @param Sql $sql 数据库语句
     * @param int $number
     * @param int $start
     * ----------------------------------------------------------
     * @return array
     * ----------------------------------------------------------
     */
    public function QueryRows(Sql $sql, $number, $start = 0)
    {
        // TODO: Implement QueryRows() method.
    }

    /**
     * ----------------------------------------------------------
     * 获取一个查询值
     * ----------------------------------------------------------
     * @param Sql $sql
     * @param $name
     * ----------------------------------------------------------
     * @return mixed
     * ----------------------------------------------------------
     */
    public function QueryValue(Sql $sql, $name)
    {
        // TODO: Implement QueryValue() method.
    }

    /**
     * ----------------------------------------------------------
     * 进行分页查询
     * ----------------------------------------------------------
     * @param Sql $sql
     * @param $current
     * @param $number
     * ----------------------------------------------------------
     * @return Page
     * ----------------------------------------------------------
     */
    public function Page(Sql $sql, $current, $number)
    {
        // TODO: Implement Page() method.
    }

    /**
     * ----------------------------------------------------------
     * 统计记录数
     * ----------------------------------------------------------
     * @param Sql $sql
     * ----------------------------------------------------------
     * @return int
     * ----------------------------------------------------------
     */
    public function Count(Sql $sql)
    {
        // TODO: Implement Count() method.
    }

    /**
     * ----------------------------------------------------------
     * 执行Sql语句
     * ----------------------------------------------------------
     * @param string $sql
     * ----------------------------------------------------------
     * @return int
     * ----------------------------------------------------------
     */
    public function Excuse($sql)
    {
        // TODO: Implement Excuse() method.
    }

    /**
     * ----------------------------------------------------------
     * 执行插入操作
     * ----------------------------------------------------------
     * @param string $table
     * @param array $data
     * ----------------------------------------------------------
     * @return int
     * ----------------------------------------------------------
     */
    public function Insert($table, array $data)
    {
        // TODO: Implement Insert() method.
    }

    /**
     * ----------------------------------------------------------
     * 执行修改操作
     * ----------------------------------------------------------
     * @param Sql $sql
     * @param array $data
     * ----------------------------------------------------------
     * @return int
     * ----------------------------------------------------------
     */
    public function Update(Sql $sql, array $data)
    {
        // TODO: Implement Update() method.
    }

    /**
     * ----------------------------------------------------------
     * 执行删除操作
     * ----------------------------------------------------------
     * @param Sql $sql
     * ----------------------------------------------------------
     * @return int
     * ----------------------------------------------------------
     */
    public function Delete(Sql $sql)
    {
        // TODO: Implement Delete() method.
    }

    /**
     * ----------------------------------------------------------
     * 数据表清空操作
     * ----------------------------------------------------------
     * @param string $table
     * ----------------------------------------------------------
     * @return bool
     * ----------------------------------------------------------
     */
    public function Clean($table)
    {
        // TODO: Implement Clean() method.
    }

    /**
     * 事物方式执行
     * @param mixed $excuse
     * @param null $success
     * @param null $error
     * @return mixed
     */
    public function Transaction($excuse, $success = null, $error = null)
    {
        // TODO: Implement Transaction() method.
    }

    /**
     * ----------------------------------------------------------
     * 创建对象拾取器
     * ----------------------------------------------------------
     * @return Picker
     * ----------------------------------------------------------
     */
    function NewPicker()
    {
        // TODO: Implement NewPicker() method.
    }

    /**
     * ----------------------------------------------------------
     * 创建Sql构造器
     * ----------------------------------------------------------
     * @return Sql
     * ----------------------------------------------------------
     */
    function NewSql()
    {
        // TODO: Implement NewSql() method.
    }
}